#include <STC89C5xRC.H>
#include <INTRINS.H>

void Delay(unsigned int xms)		//@11.0592MHz
{
	unsigned char i, j;
	while(xms)
	{
		nop_();
		i = 2;
		j = 199;
		do
		{
			while (--j);
		} while (--i);
		xms--;
	}
	
}


void main()
{
	while(1)
	{	
		if(P31==0)
		{
			Delay(20);
			while(P31==0);
			Delay(20);
			while(P31==1)
			{
				P2=0xFE;
				Delay(100);
				P2=0xFD;
				Delay(100);
				P2=0xFB;
				Delay(100);
				P2=0xF7;
				Delay(100);
				P2=0xEF;
				Delay(100);
				P2=0xDF;
				Delay(100);
				P2=0xBF;
				Delay(100);
				P2=0x7F;
				Delay(100);
			}
			P2=0xFF;
		}
		else
		{
			P2=0xFF;
		}

	}
}